#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd $DIR/../.. || exit 2
LITEMALL_HOME=$PWD
echo "LITEMALL_HOME $LITEMALL_HOME"

# 项目打包
cd $LITEMALL_HOME || exit 2
chmod +x ./deploy/util/package.sh
./deploy/util/package.sh

# 远程登录云服务器并执行reset脚本
# 这里使用tr命令，因为有可能deploy.sh和reset.sh的换行格式是CRLF，而LINUX环境应该是LF
cd /home/deploy/litemall/deploy/bin/
cat deploy.sh | tr -d '\r' > deploy2.sh
mv deploy2.sh deploy.sh
chmod +x deploy.sh